package com.bjsy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjsy.mapper.BookMapper;
import com.bjsy.pojo.Book;
import com.bjsy.service.BookService;
import com.bjsy.vo.BookVo;
import com.bjsy.vo.Result;
import com.bjsy.vo.ResultEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 作者
 * @since 2022-01-19
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {

    //获取映射对象
    //private BookMapper bookMapper = new BookMapper();
    @Autowired
    private BookMapper bookMapper;

    @Override
    public Result getAllBook() {
        List<BookVo> bookVoList = bookMapper.getAllBook();
        //判空
        if (!CollectionUtils.isEmpty(bookVoList)) {
            return Result.success(bookVoList);
        }
        return Result.fail(ResultEnum.QUERY_FAIL);
    }
}
